<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" encoding="UTF-8" indent="yes"/>
    
    <!-- 图片处理模板 -->
    <xsl:template name="image-template">
        <xsl:param name="imageNode"/>
        <xsl:if test="$imageNode">
            <div class="image-container">
                <img>
                    <xsl:attribute name="src">
                        <xsl:value-of select="$imageNode/imageUrl"/>
                    </xsl:attribute>
                    <xsl:attribute name="alt">
                        <xsl:value-of select="$imageNode/imageAlt"/>
                    </xsl:attribute>
                    <xsl:if test="$imageNode/imageWidth">
                        <xsl:attribute name="width">
                            <xsl:value-of select="$imageNode/imageWidth"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:if test="$imageNode/imageHeight">
                        <xsl:attribute name="height">
                            <xsl:value-of select="$imageNode/imageHeight"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:attribute name="class">responsive-image</xsl:attribute>
                    <xsl:attribute name="loading">lazy</xsl:attribute>
                </img>
            </div>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="/">
        <html>
            <head>
                <title>基金产品概要</title>
                <meta charset="UTF-8"/>
                <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
                <style>
                    /* 重置样式 */
                    * {
                        margin: 0;
                        padding: 0;
                        box-sizing: border-box;
                    }
                    
                    body {
                        font-family: "SimSun", "Microsoft YaHei", sans-serif;
                        line-height: 1.6;
                        color: #000;
                        background-color: #fff;
                        font-size: 14px;
                    }
                    
                    /* 页面布局 */
                    .page {
                        width: 210mm;
                        min-height: 297mm;
                        padding: 20mm;
                        margin: 0 auto;
                        background: white;
                        box-shadow: 0 0 10px rgba(0,0,0,0.1);
                    }
                    
                    /* 文档信息 */
                    .document-info {
                        text-align: right;
                        font-size: 12px;
                        color: #666;
                        margin-bottom: 20px;
                        border-bottom: 1px solid #ddd;
                        padding-bottom: 10px;
                    }
                    
                    /* 页眉 */
                    .header {
                        text-align: center;
                        margin-bottom: 20px;
                        padding-bottom: 15px;
                        border-bottom: 2px solid #000;
                    }
                    
                    .fund-name {
                        font-size: 24px;
                        font-weight: bold;
                        margin-bottom: 5px;
                    }
                    
                    .fund-code {
                        font-size: 16px;
                        color: #333;
                    }
                    
                    /* 章节样式 */
                    .section {
                        margin-bottom: 20px;
                        page-break-inside: avoid;
                    }
                    
                    .section-title {
                        font-size: 16px;
                        font-weight: bold;
                        margin-bottom: 10px;
                        padding-bottom: 5px;
                        border-bottom: 1px solid #000;
                    }
                    
                    /* 表格样式 */
                    table {
                        width: 100%;
                        border-collapse: collapse;
                        margin: 10px 0;
                        font-size: 14px;
                    }
                    
                    th, td {
                        border: 1px solid #000;
                        padding: 8px;
                        text-align: left;
                    }
                    
                    th {
                        background-color: #f5f5f5;
                        font-weight: bold;
                    }
                    
                    /* 信息网格 */
                    .info-grid {
                        display: grid;
                        grid-template-columns: repeat(2, 1fr);
                        gap: 10px;
                        margin: 10px 0;
                    }
                    
                    .info-item {
                        margin-bottom: 8px;
                    }
                    
                    .label {
                        font-weight: bold;
                        margin-bottom: 3px;
                    }
                    
                    .value {
                        color: #000;
                    }
                    
                    /* 风险等级标签 */
                    .risk-level {
                        display: inline-block;
                        padding: 2px 8px;
                        border: 1px solid #000;
                        font-weight: bold;
                    }
                    
                    /* 图片容器 */
                    .image-container {
                        margin: 15px 0;
                        text-align: center;
                    }
                    
                    .responsive-image {
                        max-width: 100%;
                        height: auto;
                        border: 1px solid #ddd;
                    }
                    
                    .chart-container {
                        margin: 15px 0;
                        padding: 10px;
                        border: 1px solid #ddd;
                    }
                    
                    .image-caption {
                        margin-top: 5px;
                        text-align: center;
                        font-size: 12px;
                        color: #666;
                    }
                    
                    /* 风险因素列表 */
                    .risk-factors {
                        list-style-type: none;
                        margin: 10px 0;
                    }
                    
                    .risk-factor {
                        margin-bottom: 10px;
                        padding-left: 20px;
                        position: relative;
                    }
                    
                    .risk-factor:before {
                        content: "•";
                        position: absolute;
                        left: 0;
                        color: #000;
                    }
                    
                    /* 免责声明 */
                    .disclaimer {
                        margin-top: 30px;
                        padding: 15px;
                        border: 1px solid #ddd;
                        background-color: #f9f9f9;
                        font-size: 12px;
                        color: #666;
                    }
                    
                    /* 打印样式 */
                    @media print {
                        body {
                            background: none;
                        }
                        
                        .page {
                            width: 100%;
                            min-height: auto;
                            padding: 0;
                            margin: 0;
                            box-shadow: none;
                        }
                        
                        .section {
                            page-break-inside: avoid;
                        }
                        
                        .image-container {
                            page-break-inside: avoid;
                        }
                        
                        table {
                            page-break-inside: avoid;
                        }
                        
                        .disclaimer {
                            position: fixed;
                            bottom: 0;
                            left: 0;
                            right: 0;
                            border: none;
                            background: none;
                        }
                    }
                </style>
            </head>
            <body>
                <div class="page">
                    <!-- 文档信息 -->
                    <div class="document-info">
                        <div>文档编号：<xsl:value-of select="fundProfile/documentInfo/documentId"/></div>
                        <div>文档类型：<xsl:value-of select="fundProfile/documentInfo/documentType"/></div>
                        <div>文档日期：<xsl:value-of select="fundProfile/documentInfo/documentDate"/></div>
                        <div>文档版本：<xsl:value-of select="fundProfile/documentInfo/documentVersion"/></div>
                    </div>

                    <!-- 基金基本信息 -->
                    <div class="header">
                        <xsl:if test="fundProfile/fundInfo/fundLogo">
                            <div class="image-container">
                                <xsl:call-template name="image-template">
                                    <xsl:with-param name="imageNode" select="fundProfile/fundInfo/fundLogo"/>
                                </xsl:call-template>
                            </div>
                        </xsl:if>
                        <h1 class="fund-name">
                            <xsl:value-of select="fundProfile/fundInfo/fundName"/>
                        </h1>
                        <div class="fund-code">
                            基金代码：<xsl:value-of select="fundProfile/fundInfo/fundCode"/>
                        </div>
                    </div>

                    <!-- 基金概况 -->
                    <div class="section">
                        <h2 class="section-title">一、基金概况</h2>
                        <div class="info-grid">
                            <div class="info-item">
                                <div class="label">基金类型</div>
                                <div class="value"><xsl:value-of select="fundProfile/fundInfo/fundType"/></div>
                            </div>
                            <div class="info-item">
                                <div class="label">风险等级</div>
                                <div class="value">
                                    <span class="risk-level"><xsl:value-of select="fundProfile/fundInfo/riskLevel"/></span>
                                </div>
                            </div>
                            <div class="info-item">
                                <div class="label">成立日期</div>
                                <div class="value"><xsl:value-of select="fundProfile/fundInfo/establishDate"/></div>
                            </div>
                            <div class="info-item">
                                <div class="label">基金规模</div>
                                <div class="value"><xsl:value-of select="fundProfile/fundInfo/fundSize"/></div>
                            </div>
                        </div>
                        <table>
                            <tr>
                                <th>基金管理人</th>
                                <td><xsl:value-of select="fundProfile/fundInfo/fundManager"/></td>
                            </tr>
                            <tr>
                                <th>基金托管人</th>
                                <td><xsl:value-of select="fundProfile/fundInfo/fundCustodian"/></td>
                            </tr>
                            <tr>
                                <th>基金登记机构</th>
                                <td><xsl:value-of select="fundProfile/fundInfo/fundRegistrar"/></td>
                            </tr>
                            <tr>
                                <th>会计师事务所</th>
                                <td><xsl:value-of select="fundProfile/fundInfo/fundAuditor"/></td>
                            </tr>
                            <tr>
                                <th>律师事务所</th>
                                <td><xsl:value-of select="fundProfile/fundInfo/fundLawyer"/></td>
                            </tr>
                        </table>
                    </div>

                    <!-- 基金经理信息 -->
                    <div class="section">
                        <h2 class="section-title">二、基金经理</h2>
                        <div class="info-grid">
                            <xsl:if test="fundProfile/fundManager/managerPhoto">
                                <div class="image-container">
                                    <xsl:call-template name="image-template">
                                        <xsl:with-param name="imageNode" select="fundProfile/fundManager/managerPhoto"/>
                                    </xsl:call-template>
                                </div>
                            </xsl:if>
                            <div class="info-item">
                                <div class="label">基金经理</div>
                                <div class="value"><xsl:value-of select="fundProfile/fundManager/managerName"/></div>
                            </div>
                            <div class="info-item">
                                <div class="label">职务</div>
                                <div class="value"><xsl:value-of select="fundProfile/fundManager/managerTitle"/></div>
                            </div>
                            <div class="info-item">
                                <div class="label">学历</div>
                                <div class="value"><xsl:value-of select="fundProfile/fundManager/managerEducation"/></div>
                            </div>
                            <div class="info-item">
                                <div class="label">从业年限</div>
                                <div class="value"><xsl:value-of select="fundProfile/fundManager/managerExperience"/></div>
                            </div>
                        </div>
                        <div class="info-item" style="margin-top: 10px;">
                            <div class="label">基金经理简介</div>
                            <div class="value"><xsl:value-of select="fundProfile/fundManager/managerIntroduction"/></div>
                        </div>
                        <div class="info-item" style="margin-top: 15px;">
                            <div class="label">历史业绩</div>
                            <table>
                                <tr>
                                    <th>年份</th>
                                    <th>收益率</th>
                                    <th>基准收益率</th>
                                    <th>排名</th>
                                </tr>
                                <xsl:for-each select="fundProfile/fundManager/managerPerformance/performanceItem">
                                    <tr>
                                        <td><xsl:value-of select="year"/></td>
                                        <td><xsl:value-of select="return"/></td>
                                        <td><xsl:value-of select="benchmark"/></td>
                                        <td><xsl:value-of select="rank"/></td>
                                    </tr>
                                </xsl:for-each>
                            </table>
                        </div>
                    </div>

                    <!-- 投资策略 -->
                    <div class="section">
                        <h2 class="section-title">三、投资策略</h2>
                        <div class="info-item">
                            <div class="label">投资目标</div>
                            <div class="value"><xsl:value-of select="fundProfile/investmentStrategy/investmentObjective"/></div>
                        </div>
                        <div class="info-item" style="margin-top: 10px;">
                            <div class="label">投资范围</div>
                            <div class="value"><xsl:value-of select="fundProfile/investmentStrategy/investmentScope"/></div>
                        </div>
                        <div class="info-item" style="margin-top: 10px;">
                            <div class="label">策略说明</div>
                            <div class="value"><xsl:value-of select="fundProfile/investmentStrategy/strategyDescription"/></div>
                        </div>
                        <div class="info-item" style="margin-top: 10px;">
                            <div class="label">投资风格</div>
                            <div class="value">
                                <xsl:value-of select="fundProfile/investmentStrategy/investmentStyle/style"/>：
                                <xsl:value-of select="fundProfile/investmentStrategy/investmentStyle/description"/>
                            </div>
                        </div>
                        <div class="info-item" style="margin-top: 10px;">
                            <div class="label">资产配置</div>
                            <table>
                                <tr>
                                    <th>资产类别</th>
                                    <th>配置比例</th>
                                </tr>
                                <tr>
                                    <td>股票</td>
                                    <td><xsl:value-of select="fundProfile/investmentStrategy/assetAllocation/stock"/></td>
                                </tr>
                                <tr>
                                    <td>债券</td>
                                    <td><xsl:value-of select="fundProfile/investmentStrategy/assetAllocation/bond"/></td>
                                </tr>
                                <tr>
                                    <td>现金</td>
                                    <td><xsl:value-of select="fundProfile/investmentStrategy/assetAllocation/cash"/></td>
                                </tr>
                                <tr>
                                    <td>其他</td>
                                    <td><xsl:value-of select="fundProfile/investmentStrategy/assetAllocation/other"/></td>
                                </tr>
                            </table>
                        </div>
                        <xsl:if test="fundProfile/investmentStrategy/strategyChart">
                            <div class="chart-container">
                                <xsl:call-template name="image-template">
                                    <xsl:with-param name="imageNode" select="fundProfile/investmentStrategy/strategyChart"/>
                                </xsl:call-template>
                                <div class="image-caption">图1：资产配置图</div>
                            </div>
                        </xsl:if>
                    </div>

                    <!-- 业绩表现 -->
                    <div class="section">
                        <h2 class="section-title">四、业绩表现</h2>
                        <table>
                            <tr>
                                <th>年份</th>
                                <th>收益率</th>
                                <th>基准收益率</th>
                                <th>排名</th>
                            </tr>
                            <xsl:for-each select="fundProfile/performance/yearlyReturn">
                                <tr>
                                    <td><xsl:value-of select="year"/></td>
                                    <td><xsl:value-of select="return"/></td>
                                    <td><xsl:value-of select="benchmark"/></td>
                                    <td><xsl:value-of select="rank"/></td>
                                </tr>
                            </xsl:for-each>
                        </table>
                        <xsl:if test="fundProfile/performance/performanceChart">
                            <div class="chart-container">
                                <xsl:call-template name="image-template">
                                    <xsl:with-param name="imageNode" select="fundProfile/performance/performanceChart"/>
                                </xsl:call-template>
                                <div class="image-caption">图2：业绩走势图</div>
                            </div>
                        </xsl:if>
                        <div class="info-item" style="margin-top: 10px; font-size: 12px; color: #666;">
                            <xsl:value-of select="fundProfile/performance/performanceNote"/>
                        </div>
                    </div>

                    <!-- 风险提示 -->
                    <div class="section">
                        <h2 class="section-title">五、风险提示</h2>
                        <div class="info-item">
                            <div class="label">风险等级</div>
                            <div class="value">
                                <span class="risk-level"><xsl:value-of select="fundProfile/riskDisclosure/riskLevel"/></span>
                            </div>
                        </div>
                        <div class="info-item" style="margin-top: 10px;">
                            <div class="label">风险说明</div>
                            <div class="value"><xsl:value-of select="fundProfile/riskDisclosure/riskDescription"/></div>
                        </div>
                        <div class="info-item" style="margin-top: 15px;">
                            <div class="label">主要风险因素</div>
                            <ul class="risk-factors">
                                <xsl:for-each select="fundProfile/riskDisclosure/riskFactors/riskFactor">
                                    <li class="risk-factor">
                                        <strong><xsl:value-of select="name"/>：</strong>
                                        <xsl:value-of select="description"/>
                                    </li>
                                </xsl:for-each>
                            </ul>
                        </div>
                        <xsl:if test="fundProfile/riskDisclosure/riskChart">
                            <div class="chart-container">
                                <xsl:call-template name="image-template">
                                    <xsl:with-param name="imageNode" select="fundProfile/riskDisclosure/riskChart"/>
                                </xsl:call-template>
                                <div class="image-caption">图3：风险等级图</div>
                            </div>
                        </xsl:if>
                    </div>

                    <!-- 费率结构 -->
                    <div class="section">
                        <h2 class="section-title">六、费率结构</h2>
                        <table>
                            <tr>
                                <th>费用类型</th>
                                <th>费率</th>
                            </tr>
                            <tr>
                                <td>管理费</td>
                                <td><xsl:value-of select="fundProfile/feeStructure/managementFee"/></td>
                            </tr>
                            <tr>
                                <td>托管费</td>
                                <td><xsl:value-of select="fundProfile/feeStructure/custodyFee"/></td>
                            </tr>
                            <tr>
                                <td>认购费</td>
                                <td><xsl:value-of select="fundProfile/feeStructure/subscriptionFee"/></td>
                            </tr>
                            <tr>
                                <td>赎回费</td>
                                <td><xsl:value-of select="fundProfile/feeStructure/redemptionFee"/></td>
                            </tr>
                        </table>
                        <xsl:if test="fundProfile/feeStructure/feeChart">
                            <div class="chart-container">
                                <xsl:call-template name="image-template">
                                    <xsl:with-param name="imageNode" select="fundProfile/feeStructure/feeChart"/>
                                </xsl:call-template>
                                <div class="image-caption">图4：费率结构图</div>
                            </div>
                        </xsl:if>
                        <div class="info-item" style="margin-top: 10px; font-size: 12px; color: #666;">
                            <xsl:value-of select="fundProfile/feeStructure/feeNote"/>
                        </div>
                    </div>

                    <!-- 申购信息 -->
                    <div class="section">
                        <h2 class="section-title">七、申购信息</h2>
                        <table>
                            <tr>
                                <th>最低申购金额</th>
                                <td><xsl:value-of select="fundProfile/subscriptionInfo/minSubscriptionAmount"/></td>
                            </tr>
                            <tr>
                                <th>申购方式</th>
                                <td><xsl:value-of select="fundProfile/subscriptionInfo/subscriptionMethod"/></td>
                            </tr>
                            <tr>
                                <th>申购时间</th>
                                <td><xsl:value-of select="fundProfile/subscriptionInfo/subscriptionTime"/></td>
                            </tr>
                            <tr>
                                <th>赎回时间</th>
                                <td><xsl:value-of select="fundProfile/subscriptionInfo/redemptionTime"/></td>
                            </tr>
                            <tr>
                                <th>结算时间</th>
                                <td><xsl:value-of select="fundProfile/subscriptionInfo/settlementTime"/></td>
                            </tr>
                        </table>
                    </div>

                    <!-- 免责声明 -->
                    <div class="disclaimer">
                        <xsl:value-of select="fundProfile/disclaimer/content"/>
                        <div style="margin-top: 5px; text-align: right;">
                            日期：<xsl:value-of select="fundProfile/disclaimer/date"/>
                        </div>
                    </div>
                </div>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet> 